package fyp.spedmew.connector;

import android.os.AsyncTask;
import android.util.Log;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import fyp.spedmew.backend.entity.jobEndpoint.model.Job;

/**
 * Created by Andy on 22/12/2014.
 */
public class JobListATask extends AsyncTask<Void, Void, List<Job>> {
    private static Integer MAX_RECORD = 10;
    private static final String TAG = new Object(){}.getClass().getCanonicalName();

    @Override
    protected List<Job> doInBackground(Void... params) {
        List<Job> result;
        try {
            result = ApiService.getJobEndpoint().listJob().setCount(MAX_RECORD).execute().getItems();
        } catch (IOException e) {
            Log.e(TAG, Log.getStackTraceString(e));
            result = Collections.emptyList();
        }
        return result;
    }
}